package Exercise;

//同步方法处理继承问题

public class windowTest3 {
    public static void main(String[] args) {
        window3 t1 = new window3();
        window3 t2 = new window3();
        window3 t3 = new window3();
        t1.setName("窗口一");
        t2.setName("窗口二");
        t3.setName("窗口三");

        t1.start();
        t2.start();
        t3.start();
    }
}


class window3 extends Thread {
    private static int TICKTE = 100;

    public void run() {

            while (true) {
                if(TICKTE>0)
                show();
                else{
                    break;
                }
            }

    }
    private static synchronized void show(){
        if (TICKTE > 0) {
            System.out.println(Thread.currentThread().getName() + ":卖票,票号为:" + TICKTE);
            TICKTE--;
        }
    }
}


